﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HRM.Entity;

namespace HRM.DAL
{
    public class EmployeeRewardDAL: BaseDAL
    {
        public EmployeeReward GetByID(int ID)
        {
            return Repository.Single<EmployeeReward>(item => item.ID == ID);
        }

        public List<EmployeeReward> GetByEmployee(int employeeID)
        {
            var query = from item in Repository.All<EmployeeReward>()
                        where item.EmpID == employeeID
                        select item;
            return query.ToList();
        }

        public List<EmployeeReward> GetByEmployee(int employeeID, int type)
        {
            var query = from item in Repository.All<EmployeeReward>()
                        where item.EmpID == employeeID && item.Type == type
                        select item;
            return query.ToList();
        }

        public EmployeeReward Update(EmployeeReward item)
        {
            Repository.Update<EmployeeReward>(item);
            return item;
        }

        public EmployeeReward Add(EmployeeReward item)
        {
            Repository.Add<EmployeeReward>(item);
            return item;
        }

        public void Delete(int ID)
        {
            Repository.Delete<EmployeeReward>(ID);
        }
    }
}
